<template>
	<view>
		<!-- 搜索框-->
		<view class="search-cont">
			<view class="search">
				<image src="../../../static/img/search.png" mode="widthFix" class="search-img"></image>
				<input v-model="searchaccid" type="text" maxlength="10" placeholder="请搜索账户" @input="searchAccid()" />
			</view>
		</view>
		<text style="color: #ff0000;">{{induce}}</text>
		<!-- 搜索用户信息 -->
		<view class="content" v-if="showlist ===1" @click="gotoadduserinfo()">
				<view class="content-view">
					<view class="content-img">
						<image src="../../../static/img/my.png" ></image>
					</view>
					<view class="content-title">
						<text class="conteng-take">{{userinfo.accid}}</text>
						<view class="conteng-information">
							<text>{{userinfo.name}}</text>
						</view>
					</view>
				</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				searchaccid: '',
				userinfo: {},
				// 显示查找的好友列表
				showlist:0,
				induce:''
			}
		},
		methods: {
			// 搜索客户列表
			async searchAccid() {
				let data = this.searchaccid
				let res = await this.$api.PersonInfo(data);
				console.log(res)
				this.userinfo = res.data
				console.log(this.userinfo)
				if(res.code ==0){
					this.showlist = 1
					this.induce = ''
					this.$store.dispatch('getsearchinfoaccid',this.searchaccid)
				}
				else{
					this.showlist = 0
					this.induce = res.msg
				}
			},
			// 点击跳转
			gotoadduserinfo(){
				uni.navigateTo({
					url:'/pages/addfriendinfo/addfriendinfo'
				})
			}
		}
	}
</script>

<style scoped>
	/* 搜索部分 */
	.search-img {
		margin: auto 0 auto 20rpx;
		width: 40rpx;
		height: 40rpx;
	}

	.search {
		height: 70rpx;
		line-height: 70rpx;
		width: 100%;
		display: flex;
		background: #eff3f4;
		border-radius: 10rpx;
	}

	.search input {
		height: 70rpx;
		line-height: 70rpx;
		width: 100%;
		/* font-size: 20rpx; */
		color: #666666;
	}

	.search-cont {
		display: flex;
		justify-content: space-between;
		height: 70rpx;
		align-items: center;
	}
	.content-view text{
		display: block;
	}
	.content-view{
		display: flex;
		justify-content: space-between;
		height: 80rpx;
		overflow: hidden;
		border-bottom: 1rpx solid #E4E8EF;
		padding-bottom:5rpx;
		margin: 30rpx 0;
		color: #898989;
	}
	.content-img{
		width: 40%;
		height: 200rpx;
		background-position: center;
		background-repeat: no-repeat;
		background-size: cover;
	}
	.content-img image{
		width: 100rpx;
		height: 100rpx;
	}
	.content-title{
		width: 100%;
		padding-left: 10rpx;
		font-size: 24rpx;
	}
	.conteng-take{
	    color: #333333;	
	    height: 50rpx;
	    font-size: 33rpx;
	    font-weight: bold;
	    line-height: 50rpx;
	}
</style>
